<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>If var is [not] type</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>If var is [not] type</h1>

<p>Checks whether a <a href="../Variables.htm">variable's</a> contents are numeric, uppercase, etc.</p>

<pre class="Syntax">if var is <i>type</i>
if var is not <i>type</i></pre>
<h3>Parameters</h3>
<dl>

  <dt>var</dt>
  <dd><p>The <a href="../Variables.htm">variable</a> name.</p></dd>

  <dt>type</dt>
  <dd><p>See the remarks below.</p></dd>

</dl>

<h3>Remarks</h3>
<p>Supported <em>Types</em>:</p>
<table class="info">
  <tr>
    <td width="15%">integer</td>
    <td width="85%">True if <em>var</em> is non-empty and contains a purely numeric string (decimal or hexadecimal) without a decimal point. Leading and trailing spaces and tabs are allowed. The string may start with a plus or minus sign.</td>
  </tr>
  <tr>
    <td>float</td>
    <td>True if <em>var</em> is non-empty and contains a floating point number; that is, a purely numeric string containing a decimal point. Leading and trailing spaces and tabs are allowed.  The string may start with a plus sign, minus sign, or decimal point.</td>
  </tr>
  <tr>
    <td>number</td>
    <td>True if <em>var</em> contains an integer or floating point number (each of which is described above).</td>
  </tr>
  <tr>
    <td>digit</td>
    <td>True if <em>var</em> is empty or contains only digits, which consist of the characters 0 through 9. Other characters such as the following are not allowed: spaces, tabs, plus signs, minus signs, decimal points, hexadecimal digits, and the 0x prefix.</td>
  </tr>
  <tr>
    <td>xdigit</td>
    <td>Hexadecimal digit: Same as <em>digit</em> except the characters A through F (uppercase or lowercase) are also allowed. In v1.0.44.09+, a prefix of 0x is tolerated if present.</td>
  </tr>
  <tr>
    <td>alpha</td>
    <td>True if <em>var</em> is empty or contains only alphabetic characters. False if there are any digits, spaces, tabs, punctuation, or other non-alphabetic characters anywhere in the string. For example, if <em>var</em> contains a space followed by a letter, it is <em>not</em> considered to be <em>alpha</em>.</td>
  </tr>
  <tr>
    <td>upper</td>
    <td>True if  <em>var</em> is empty or contains only uppercase characters. False if there are any digits, spaces, tabs, punctuation, or other non-uppercase characters anywhere in the string.</td>
  </tr>
  <tr>
    <td>lower</td>
    <td>True if <em>var</em> is empty or contains only lowercase characters. False if there are any digits, spaces, tabs, punctuation, or other non-lowercase characters anywhere in the string.</td>
  </tr>
  <tr>
    <td>alnum</td>
    <td>Same as <em>alpha</em> except that characters 0 through 9 are also allowed.</td>
  </tr>
  <tr>
    <td>space</td>
    <td>True if <em>var</em> is empty or contains only whitespace, which consists of the following characters: space (<a href="../Variables.htm">%A_Space%</a>), tab (<a href="../Variables.htm">%A_Tab%</a> or `t), linefeed (`n), return (`r), vertical tab (`v), and formfeed (`f).</td>
  </tr>
  <tr>
    <td>time</td>
    <td><p><a name="time"></a>True if <em>var</em> contains a valid date-time stamp, which can be all or just the leading part of the <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format. For example, a 4-digit string such as 2004 is considered valid. Use <a href="StringLen.htm">StringLen</a> to determine whether additional time components are present.</p>
      <p>Years less than 1601 are not considered valid because the operating system generally does not support them. The maximum year considered valid is 9999.</p>
      <p>The word DATE may be used as a substitute for the word TIME, with the same result.</p>
    </td>
  </tr>
</table>
<p><b>Note:</b> The operators &quot;between&quot;, &quot;is&quot;, &quot;in&quot;, and &quot;contains&quot; are <strong>not supported</strong> in <a href="../Variables.htm#Expressions">expressions</a>.</p>
<p><span class="ver">[AHK_L 42+]:</span> The system locale is ignored unless <a href="StringCaseSense.htm">StringCaseSense Locale</a> has been used.</p>

<h3>Related</h3>
<p><a href="../Variables.htm#YYYY">%A_YYYY%</a>, <a href="SetFormat.htm">SetFormat</a>, <a href="FileGetTime.htm">FileGetTime</a>, <a href="IfEqual.htm">IfEqual</a>, <a href="IfIn.htm">if var in/contains MatchList</a>, <a href="IfBetween.htm">if var between</a>, <a href="StringLen.htm">StringLen</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringLower.htm">StringUpper</a>, <a href="EnvAdd.htm">EnvAdd</a><a href="Block.htm">, Blocks</a>, <a href="Else.htm">Else</a></p>
<h3>Example</h3>
<pre class="NoIndent">if var is float
    MsgBox, %var% is a floating point number.
else if var is integer
    MsgBox, %var% is an integer.
if var is time
    MsgBox, %var% is also a valid date-time.</pre>

</body>
</html>
